/*
 * ArrayList.h
 *
 *  Created on: Mar 25, 2014
 *      Author: Anthony Varghese
 */

#ifndef ARRAYLIST_H_
#define ARRAYLIST_H_

namespace cs237list {

using std::ostream;

class ArrayList {
private:
	struct Node{
		short  v1;
		double v2;
		Node*  link; // not used in the ArrayList class
	};

public:
	ArrayList();
	ArrayList(unsigned int cap);
	virtual ~ArrayList();
	ArrayList(const ArrayList& source);
	ArrayList& operator =(const ArrayList& rhs);
	void insert(short s, double d);
	void fillRandom(double min, double max);
	void sort();
	unsigned int  search( double target );
private:
	Node* store;
	unsigned int size, capacity;
	static const unsigned int DEFAULT_SIZE = 10;

	void swapValues(unsigned int i1, unsigned int i2);
	unsigned int  indexOfSmallest( int startIndex );

	friend ostream& operator<<(ostream& os, const Node& n);
	friend ostream& operator<<(ostream& os, const ArrayList& ls);
};


ostream& operator<<(ostream& os, const ArrayList::Node& n);
ostream& operator<<(ostream& os, const ArrayList& ls);

}
#endif /* ARRAYLIST_H_ */
